1. Technical Field
The present invention relates to techniques for debugging computer programs, particularly in the field of object oriented (OO) technology.
2. Prior Art
Debuggers are software tools that can be used to diagnose computer programs and trace errors that arise during execution of the program. To support the debugger, information describing symbols and types in the program as well as information to map between source lines and the binary code is required. In the case of compiled programs, the compiler, under the control of an option, can produce this information. This extra information, generally referred to as debugging information, enables the programmer to examine the types, variables and data structures by name and to follow the execution of the program through the source code.
A number of debugging techniques can be used to enable the programmer to properly analyze a program to detect points in the program where errors occur. One such technique is to put a breakpoint into the program, a point in the program where normal operation is suspended automatically when certain conditions are met. Breakpoints are useful for program testing. They are specified by programmers so that interim results of processing can be inspected, and then the program can be restarted to continue running normally.
In traditional debuggers, breakpoints are generally set on functions or methods; program execution is suspended each time the particular function is called. This technique is very useful for traditional procedural languages which are, themselves, function-based.
However, object oriented languages are based on quite a different concept. Programs are created using a set of language tools, abstractions and constructs that support a particular form of user-defined types called "classes". Each such type associates the collection of declared data with a set of operations on that data, that is, methods are called on the data. Variables, or instances, of such types in the running programs are called objects.
A fundamental feature of object oriented programming is that classes can be related to one another by inheritance. The properties, behaviors, data and operations of a parent, or "base", class may be inherited without modification by some child, or "derived", class, or the behavior, properties and operations may be selectively refined under the control of the programmer in the derived class. The latter function is generally referred to as overriding. The function name remains the same, but the changed or overridden function operates on a different type. When defining a derived class, one may start by building on an existing base class which is similar to the one to be created. The derived class inherits the implementation and behavior of the base class, including its functions, except as modified by overriding amendments detailed in the derived class definition. Several classes can inherit the behaviors of a common parent, and a derived class may inherit from more than one base class.
Thus, in object oriented programs, each object defines an independent unit, and methods are called on the object. When an object becomes corrupted or otherwise mutates into a bad state, it can typically be assumed that this is caused by some method called on the object. The debugging issue, then, is to determine which method called on the object is causing the problem. Using a traditional debugger, an immense amount of superfluous information may be gathered, adding unnecessary complexity. This is because the methods that may be called for one object may also be called on any other object of the same class or type. (The construction of an object in memory is discussed in further detail below). In a normal program, thousands of instances of the class may be created in a running program. A breakpoint set on a method, then, will cause program execution to stop at each instance of the class by the method, both at the particular object being investigated and at all other instances in the class.
The continued emphasis in traditional debuggers on procedural debugging fails to take advantage of object oriented design.